using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace interfaces
{
    public static class interf
    {
		public static int iNumberOfAnalysisParameters = 6, iNumberOfAnalysisOption = 6, iNumberOfMeasures = (int)Keyword.m_input_code.Length;
        public static string[] strAnalysisParameter = new string[iNumberOfAnalysisParameters];
        public static string[] strAnalysisOption = new string[iNumberOfAnalysisOption];
        public static string[] strMeasureCode = new string[iNumberOfMeasures];
        public static string[] strInterfaceParameterType = new string[iNumberOfMeasures];
        public static double[] dApplicationPercentage = new double[iNumberOfMeasures];
        public static string[] strCurrent = new string[iNumberOfMeasures];
        public static string[] strModified = new string[iNumberOfMeasures];
        public static double[] dParameter1 = new double[iNumberOfMeasures];
        public static double[] dParameter2 = new double[iNumberOfMeasures];
        public static string[] strParameter = new string[iNumberOfMeasures];


        /// <summary>
        /// system string[] parameter index
        /// </summary>
        public enum BEE_SystemInput_T
        {
            ProgramPath_ST,     // program installation path to know where files can be found for this program
            NUM_ST
        };


		/// <summary>
		/// building information input, indexing all double type building information.
		/// </summary>
		public enum BEE_BuildingInput_T
		{
			TotalArea_BIT,				// total floor area,						user-input
			ConditionedArea_BIT,		// conditioned floor area,					user-input
			WWR_BIT,					// WWR,										user-input
			WallU_BIT,					// Wall U value								user-input
			RoofU_BIT,					// Roof U value								user-input
			Infiltration_BIT,			// Infiltration rate						user-input
			Refrigeration_BIT,			// refrigeration, 0 for no, 1 for yes,		user-input
			NUM_BIT
		};


		/// <summary>
		/// indicate whether energy is energy amount in [MWH] or [GJ] or energy cost [RMB].
		/// </summary>
		public enum BEE_Energy_T
		{
			EnergyAmount_ET,
			EnergyCost_ET,
			NUM_ET
		};


		/// <summary>
		/// global factor to scale energy based on energy consumption type, and controls
		/// These factors are created to match simulated building energy to real end use energy.
		/// </summary>
		public enum BEE_EnergyFactor_T
		{ 
			Heating_EFT,
			AirCond_EFT,
			Lighting_EFT,
			IntEquip_EFT,
			Refrig_EFT,
			DHW_EFT,
			NUM_EFT
		}


        /// <summary>
        /// keyword string copied from keyword class
        /// </summary>
		public static List<string> BEE_strMeasureCode = Keyword.m_keyword; // new string[] { 
 //           "C1_KWT", "C2_KWT", "C3_KWT", "C4_KWT", "C5_KWT", "C6_KWT", "C7_KWT", "C8_KWT", "C9_KWT",
 //           "D1_KWT", "D2_KWT", "D3_KWT", "D4_KWT",
 //           "E1_KWT", "E2_KWT", "E3_KWT", "E4_KWT", "E5_KWT", "E6_KWT", "E7_KWT", "F1_KWT",
 //           "G1_KWT", "G2_KWT", "G3_KWT", "G7_KWT",
 //           "H2_KWT"
 //       };

        /// <summary>
        /// measure input string for discrete variable
        /// </summary>
//		public static string[][] BEE_strMeasureInputOptions = Keyword.m_inputs; //new string[][] { 
//            new string[] { "Light", "Medium", "Dark" }, // C1_KWT
//            new string[] { "0.4", "0.7", "1.0", "1.3", "1.6" }, // C2_KWT
//            new string[] { "0.09", "0.36", "0.63", "0.9" }, // C3_KWT
//            new string[] { "Light", "Medium", "Dark" }, // C4_KWT
//            new string[] { "0.4", "0.6", "0.8", "1.0", "1.2", "1.4", "1.6" }, // C5_KWT
//            new string[] { "" }, // C6_KWT
//            new string[] { "Single pane", "Double pane", "Double pane reflective" }, // C7_KWT
//            new string[] { "Yes", "No" }, // C8_KWT
//            new string[] {"Aluminum w/o insulation", "Aluminum w/ insulation"}, // C9_KWT
//            new string[] { "T12", "T5" }, // D1_KWT
//            new string[] { "No", "Yes" }, // D2_KWT
//            new string[] { "No", "Yes" }, // D3_KWT
//            new string[] { "No", "Yes" }, // D4_KWT
//            new string[] { "" }, // E1_KWT
//            new string[] { "" }, // E2_KWT
//            new string[] { "1.5", "1.2" }, // E3_KWT
//            new string[] { "Const speed", "VFD" }, // E4_KWT
//            new string[] { "0.7", "0.9" }, // E5_KWT
//            new string[] { "Const speed", "VFD" }, // E6_KWT
//            new string[] { "Const speed", "VFD" }, // E7_KWT
//            new string[] { "Normal", "High" }, // F1_KWT
//            new string[] { "No", "Yes" }, // G1_KWT
//            new string[] { "No", "Yes" }, // G2_KWT
//            new string[] { "25 (Summer)", "26.5 (Summer)" }, // G3_KWT
//           new string[] { "No", "Yes" }, // G4_KWT
//            new string[] { "No", "Yes" } // H2_KWT
//        };


		/// <summary>
		/// input parameter type, continuous or discrete
		/// this is version2 definition to replace BEE_Input_T defined in before.
		/// </summary>
		public enum BEE_Input_T
		{
			Continuous_IT,
			Discrete_IT,
			NUM_OT
		};

        /// <summary>
        /// each measure's parameter type defined by BEE_Input_T
        /// </summary>
		public static BEE_Input_T[] BEE_enumMeasureInputType = new BEE_Input_T[]
        {
			BEE_Input_T.Discrete_IT,	// 030101
			BEE_Input_T.Continuous_IT,	// 030102
			BEE_Input_T.Continuous_IT,	// 030201
			BEE_Input_T.Discrete_IT,	// 030301
			BEE_Input_T.Continuous_IT,	// 030302
			BEE_Input_T.Continuous_IT,	// 030401
			BEE_Input_T.Discrete_IT,	// 030501
			BEE_Input_T.Discrete_IT,	// 030502
			BEE_Input_T.Discrete_IT,	// 030601
			BEE_Input_T.Continuous_IT,	// 050101
			BEE_Input_T.Continuous_IT,	// 050201
			BEE_Input_T.Discrete_IT,	// 050401
			BEE_Input_T.Discrete_IT,	// 050402
			BEE_Input_T.Discrete_IT,	// 050501
			BEE_Input_T.Discrete_IT,		// 060101
			BEE_Input_T.Discrete_IT		// 060102
        };

        /// <summary>
        /// the output object type.
        /// </summary>
        public enum BEE_Output_T
        {
            Original_OT,        // original energy output
            Retrofit_OT,        // after retrofit energy output
            Difference_OT,      // difference retrofit - original
			SavingRatio_OT,     // saving ratio = diff / original
			LifeCycle_OT,		// life cycle = annual * year
            NUM_OT
        };


        /// <summary>
        /// Building type enum.
        /// </summary>
        public enum BEE_Building_T
        {
			ShoppingMall_BT,	// shopping mall
			Hotel,				// hotel
			Office_BT,			// office building
			Hospital,			// hospital
			School,				// school
			Other,				// other building type
			NUM_BT
        };


		/// <summary>
		/// Building type strings, access via BEE_Building_T
		/// </summary>
		public static string[] BEE_strBuilding_T = new string[]
		{ 
			"ShoppingMall",
			"Hotel",
			"Office",
			"Hospital",
			"School",
			"Other"
		};


        /// <summary>
        /// Data level type enum.
        /// </summary>
		public enum BEE_DataLevel_T
		{
			Prototype_DLT,						// prototype
			ModifiedPrototype_DLT,				// modified prototype
			FullDescription_DLT,				// full description
			FullDescriptionOptimization_DLT,	// full description with optimization
			NUM_DLT
		};
        

        /// <summary>
        /// Prototype shape type enum.
        /// </summary>
		public enum BEE_PrototypeShape_T
		{
			Square_PST,			// square shape
			Rectangle_PST,		// rectangle
			HollowCore_PST,		// hollow core
			LShape_SPT,			// L shape
			NUM_CT
		};
		

		/// <summary>
        /// Climate type enum.
        /// </summary>
		public enum BEE_ClimateZone_T
		{
			SevereCold_CZT,				// severe cold climate zone (harbin, Shenyang)
			Cold_CZT,					// cold climate zone (Beijing)
			HotSummerColdWinter_CZT,	// hot summer cold winter (Shanghai)
			HotSummerWarmWinter_CZT,	// hot summer wearm winter (Guangzhou)
			Temperate_CZT,				// temperate (Kunming)
			NUM_CZT
		};
		

		/// <summary>
        /// Economic analysis level type enum.
        /// </summary>
		public enum BEE_EconomicLevel_T
		{
			Default_ELT,
			EnergyTariffs_ELT,
			EnergyPeakTariffs_ELT,
			EnergyTariffsECM_ELT,
			EnergyPeakTariffsECM_ELT,
			InputOptimization_ELT,
			NUM_ELT
		};
		

		/// <summary>
        /// Output level definition enum.
        /// </summary>
		public enum BEE_OutputLevel_T
		{
			Minimum_OLT,
			Medium_OLT,
			Detailed_OLT,
			NUM_OLT
		};


        /// <summary>
        /// analysis option type to define each level of BEE_strAnalysisOptions array.
        /// </summary>
        public enum BEE_AnalysisOption_T
		{
			BuildingType_AOT,
			DataLevel_AOT,
			PrototypeShape_AOT,
			ClimateZone_AOT,
			EconomicLevel_AOT,
			OutputLevel_AOT,
			NUM_AOT
		};


		public static string[] BEE_strAnalysisOptionType = new string[]
		{
			"BuildingType",
			"DataLevel",
			"PrototypeShape",
			"ClimateZone",
			"EconomicLevel",
			"OutputLevel"
		};


        /// <summary>
		/// Program input analysis option.
		/// Please access this array by using BEE_AnalysisOption_T enum for the 1st dimension element.
		/// To use each specific enum to access its 2nd dimension element.
        /// </summary>
        public static string[][] BEE_strAnalysisOptions = new string[][] { 
            new string[] { "ShoppingMall", "Hotel", "Office", "Hospital", "School", "Other", "None" }, // Building Type
            new string[] { "Prototype", "ModifiedPrototype", "FullBuildingDescription", "FullDescriptionInputOptimization", "None" }, // Data Level
            new string[] { "Square", "Rectangle", "HollowCore", "L_Shape", "None" }, // Prototype
            new string[] { "SevereCold", "Cold", "Hot Summer Cold Winter", "Hot Summer Warm Winter", "Temperate", "Other", "None" }, // Building Location
            new string[] { "Default", "EnergyTariffs", "EnergyPeakTariffs", "EnergyTariffsECM", "EnergyPeakTariffsECM", "InputOptimization", "None" }, // Economic Analysis Level
            new string[] { "Minimum", "Medium", "Detailed", "None" } // Output Level
        };

		/// <summary>
		/// Program language option
		/// </summary>
		public enum BEE_Language_T
		{
			English_LT,
			Chinese_LT,
			NUM_LT
		};

		/// <summary>
		/// Program language texts
		/// </summary>
		public static string[] BEE_strLanguageType = new string[]
		{
			"English",
			"Chinese"
		};


        public static void EncodeParameters(int iBuildingParameterNumber, string strOwner, string strName, double dFloorArea, double dConditionedFloorArea,
            double dDiscountRate, int iEvaluationPeriod, string strOtherParameters,
            int iAnalysisOptionNumber, int iBuildingTypeIndex, int iDataLevelIndex, int iPrototypeIndex, int iBuildingLocationIndex,
            int iEconomicAnalysisLevelIndex, int iOutputLevelIndex, string strOtherOptions,
            int iMeasureNumber, double[] dApplicationPercentageInput, string[] strCurrentInput, string[] strModifiedInput,
            double[] dParameter1Input, double[] dParameter2Input, string[] strParameterInput)
        {
            if (iBuildingParameterNumber != iNumberOfAnalysisParameters || iAnalysisOptionNumber != iNumberOfAnalysisOption || iMeasureNumber != iNumberOfMeasures)
            {
                MessageBox.Show("Error in Simulation Interface Parameters!");
            }

            strAnalysisParameter[0] = strOwner;
            strAnalysisParameter[1] = strName;
            strAnalysisParameter[2] = dFloorArea.ToString("N3");
            strAnalysisParameter[3] = dConditionedFloorArea.ToString("N3");
            strAnalysisParameter[4] = dDiscountRate.ToString("N3");
            strAnalysisParameter[5] = iEvaluationPeriod.ToString("N3");

            strAnalysisOption[0] = BEE_strAnalysisOptions[0][iBuildingTypeIndex];
            strAnalysisOption[1] = BEE_strAnalysisOptions[1][iDataLevelIndex];
            strAnalysisOption[2] = BEE_strAnalysisOptions[2][iPrototypeIndex];
            strAnalysisOption[3] = BEE_strAnalysisOptions[3][iBuildingLocationIndex];
            strAnalysisOption[4] = BEE_strAnalysisOptions[4][iEconomicAnalysisLevelIndex];
            strAnalysisOption[5] = BEE_strAnalysisOptions[5][iOutputLevelIndex];

            for (int i = 0; i < iNumberOfMeasures; i++)
            {
                strMeasureCode[i] = string.Copy(BEE_strMeasureCode[i]);

                dApplicationPercentage[i] = dApplicationPercentageInput[i];

				// continuous variable
                if (interf.BEE_enumMeasureInputType[i] == interf.BEE_Input_T.Continuous_IT)
                {
//                    strInterfaceParameterType[i] = BEE_strInterfaceParameterType[0];
//                    strCurrent[i] = string.Copy(strCurrentInput[i]);
//                    strModified[i] = string.Copy(strModifiedInput[i]);
                }
				// discrete variable
                else
                {
//                    strInterfaceParameterType[i] = BEE_strInterfaceParameterType[1];
//					int current_idx = Keyword.m_inputs_selected[i][Convert.ToInt32(strCurrentInput[i])];
//					strCurrent[i] = string.Copy(Keyword.m_inputs[i][current_idx]);
//					int modified_idx = Keyword.m_inputs_selected[i][Convert.ToInt32(strModifiedInput[i])];
//					strModified[i] = string.Copy(Keyword.m_inputs[i][modified_idx]);
                }

                dParameter1[i] = dParameter1Input[i];
                dParameter2[i] = dParameter2Input[i];
                strParameter[i] = string.Copy(strParameterInput[i]);
            }
        }

    }

}
